package cn.bs.busuo.front.content.dao.persist.repository.impl;

import cn.bs.busuo.common.pojo.vo.PageData;
import cn.bs.busuo.front.content.dao.persist.mapper.UserSightArticleDetailMapper;
import cn.bs.busuo.front.content.dao.persist.mapper.UserSightArticleMapper;
import cn.bs.busuo.front.content.dao.persist.repository.UserSightArticle;
import cn.bs.busuo.front.content.pojo.entity.ContentHotelArticleDetail;
import cn.bs.busuo.front.content.pojo.entity.ContentSightArticle;
import cn.bs.busuo.front.content.pojo.entity.ContentSightArticleDetail;
import cn.bs.busuo.front.content.pojo.vo.ContentSightArticleByTitleVO;
import cn.bs.busuo.front.content.pojo.vo.ContentSightArticleDetailByIdVO;
import cn.bs.busuo.front.content.pojo.vo.UserContentSightArticleByIdVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author: Feng
 * @since: 2023/12/8
 */
@Repository
public class UserSightArticleImpl implements UserSightArticle {

    @Autowired
    private UserSightArticleMapper userSightArticleMapper;

    @Autowired
    private UserSightArticleDetailMapper userSightArticleDetailMapper;

    //判断文章标题是否存在
    @Override
    public int contentSightArticleByTitle(String title) {
        return userSightArticleMapper.contentSightArticleByTitle(title);
    }

    //添加文章
    @Override
    public int addNewSightArticle(ContentSightArticle contentSightArticle) {
        return userSightArticleMapper.insert(contentSightArticle);
    }

    //根据景点文章标题查询Id
    @Override
    public Long selectSightArticleByTitle(String title) {
        return userSightArticleMapper.selectSightArticleByTitle(title);
    }

    //添加文章到详情
    @Override
    public int addNewSightArticleDetail(ContentSightArticleDetail contentSightArticleDetail) {
        return userSightArticleDetailMapper.insert(contentSightArticleDetail);
    }

    //根据景点文章Id,查询景点文章是否真实存在
    @Override
    public ContentSightArticle selectSightArticleById(Long id) {
        return userSightArticleMapper.selectSightArticleById(id);
    }

    //用户删除文章(修改为不显示)
    @Override
    public int updateSightArticleById(Long id) {
        return userSightArticleMapper.updateSightArticleById(id);
    }

    //根据景点Id查询景点文章
    @Override
    public List<UserContentSightArticleByIdVO> selectSightArticleBySightId(Long id) {
        return userSightArticleMapper.selectSightArticleBySightId(id);
    }

    //查看景点文章详情
    @Override
    public ContentSightArticleDetailByIdVO selectSightArticleDetailById(Long id) {
        return userSightArticleDetailMapper.selectSightArticleDetailById(id);
    }

    //增加点击量
    @Override
    public void increaseClickCount(Long id) {
        userSightArticleDetailMapper.increaseClickCount(id);
    }

    //增加点赞量
    @Override
    public int increaseUpCount(Long id) {
        return userSightArticleMapper.increaseUpCount(id);
    }

    //增加差评
    @Override
    public int increaseDownCount(Long id) {
        return userSightArticleMapper.increaseDownCount(id);
    }

    //增加景点评论量
    @Override
    public void increaseCommentCount(Long id) {
         userSightArticleMapper.increaseCommentCount(id);
    }

    //查询自己的景点文章
    @Override
    public List<UserContentSightArticleByIdVO> selectUserListSightArticle(String authorName) {
        return userSightArticleMapper.selectUserListSightArticle(authorName);
    }

    //查看景点文章实体类
    @Override
    public ContentHotelArticleDetail selectSightArticleDetail(Long id) {
        return userSightArticleDetailMapper.selectHotelArticleDetail(id);
    }

    //修改景点文章
    @Override
    public int updateSightArticle(String title,String brief,String coverUrl,String keywords,Long id) {
        return userSightArticleMapper.updateSightArticle(title,brief,coverUrl,keywords,id);
    }

    //修改景点文章详情
    @Override
    public int updateHotelArticleDetail(String detail, Long id) {
        return userSightArticleDetailMapper.updateHotelArticleDetail(detail,id);
    }

    //根据文章标题查询景点文章存入redis
    @Override
    public ContentSightArticleByTitleVO selectSightArticleByTitleVO(String title) {
        return userSightArticleMapper.selectSightArticleByTitleVO(title);
    }

}
